package com.song.shop.nio;

import java.io.*;
import java.net.Socket;

/**
 * @author Song Yinghui
 * @date 2019/2/13
 * @Version 1.0
 */
public class ThreadServerUtils extends Thread {

    public ThreadServerUtils(Socket socket){
        Runnable runnable = () -> {
            try {
                InputStream inputStream = socket.getInputStream();
                InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
                BufferedReader br =new BufferedReader(inputStreamReader);
                String info = null ;
                while ((info = br.readLine()) != null){
                    System.out.println(info);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        };

        new Thread(runnable).start();
    }
}
